package com.kaili.basic.controller.pda.v1;

import com.baomidou.mybatisplus.plugins.Page;
import com.kaili.basic.pojo.dto.*;
import com.kaili.basic.pojo.entity.BasicSite;
import com.kaili.basic.service.BaseCityService;
import com.kaili.basic.service.BasicSiteService;
import com.kaili.basic.version.ApiVersion;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author zhangjl
 * @Type BasicSiteController
 * @Desc 杭州凯立通信有限公司
 * @Date 2018年04月26日
 */

@ApiVersion(1)
@RequestMapping("/{api_version}")
@RestController("baseSiteControllerP")
@Validated
@Api(tags = "[pad]网点管理", description = "[pad]网点管理相关API")
public class BaseSiteController {

    @Autowired
    private BasicSiteService basicSiteService;

    @Autowired
    private BaseCityService baseCityService;
    /**
     * 分页条件查询列表
     * @param baseSiteQueryDto
     * @return
     */
    @ApiOperation(value = "分页条件查询列表", notes = "分页条件查询列表")
    @GetMapping(value = "p/baseSite/page")
    public Page<BasicSite> listBasicSite(@ModelAttribute BaseSiteQueryDto baseSiteQueryDto) {
        BasicSite basicSite = new BasicSite();
        basicSite.setSiteName(baseSiteQueryDto.getSiteName());
        basicSite.setCityName(baseSiteQueryDto.getCityName());
        basicSite.setContacts(baseSiteQueryDto.getContacts());
        basicSite.setSiteCode(baseSiteQueryDto.getSiteCode());
        basicSite.setPage(baseSiteQueryDto.getPage());
        basicSite.setPageSize(baseSiteQueryDto.getPageSize());
        return basicSiteService.listBasicSite(new Page<BasicSite>(basicSite.getPage(), basicSite.getPageSize()), basicSite);
    }

    @ApiOperation(value = "获取区县", notes = "获取区县")
    @GetMapping("p/baseSite/county")
    public List<Map> getCounty() {
        return baseCityService.getCounty();
    }

    @ApiOperation(value = "获取城市", notes = "获取城市")
    @GetMapping("p/baseSite/city")
    public List<Map> getCity() {
        return baseCityService.getCity();
    }

    @ApiOperation(value = "获取省份", notes = "获取省份")
    @GetMapping("p/baseSite/province")
    public List<Map> getProvince() {
        return baseCityService.getProvince();
    }

    @ApiOperation(value = "获取地址", notes = "获取地址")
    @GetMapping("p/baseSite/area")
    public List<Map> getArea() {
        return baseCityService.getArea();
    }
}
